package com.asm.controller.api;

import com.asm.controller.BaseController;
import com.asm.dto.Result;
import com.asm.service.SpotTagService;
import com.asm.vo.sys.SpotTagVo;
import io.swagger.annotations.*;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author ZhuangGuiMan
 */
@RestController
@Api(value = "广告位标签Controller")
public class SpotTagController extends BaseController {
    @Resource
    private SpotTagService spotTagService;

    /**
     * 添加广告位标签
     *
     * @param spotTagVo 广告位标签
     * @return 操作状态
     */
    @ApiOperation("接口描述：添加广告位标签")
    @PostMapping("/spotTag/add")
    public ResponseEntity<Result> addSpotTag(@RequestBody @ApiParam(name = "spotTagVo", value = "广告位标签视图对象") SpotTagVo spotTagVo) {
        spotTagService.addSpotTag(spotTagVo);
        return new ResponseEntity<>(new Result().ok("add success"), HttpStatus.OK);
    }

    /**
     * 删除广告位标签
     *
     * @param id 广告位标签编号
     * @return 操作状态
     */
    @ApiOperation("接口描述：删除广告位标签")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "广告位标签编号")
    })
    @DeleteMapping("/spotTag/delete/{id}")
    public ResponseEntity<Result> deleteSpotTag(@PathVariable Long id) {
        spotTagService.deleteSpotTag(id);
        return new ResponseEntity<>(new Result().ok("delete success"), HttpStatus.OK);
    }

    /**
     * 更新广告位标签
     *
     * @param spotTagVo 广告位标签
     * @return 操作状态
     */
    @ApiOperation("接口描述：更新广告位标签")
    @PutMapping("/spotTag/update")
    public ResponseEntity<Result> updateSpotTag(@RequestBody @ApiParam(name = "spotTagVo", value = "广告位标签视图对象") SpotTagVo spotTagVo) {
        spotTagService.updateSpot(spotTagVo);
        return new ResponseEntity<>(new Result().ok("update success"), HttpStatus.OK);
    }
}
